package com.tenglong.teacher.ui.publish;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.MotionEvent;

import cn.hzw.doodle.DoodleView;
import cn.hzw.doodle.IDoodleListener;
import cn.hzw.doodle.core.IDoodleTouchDetector;

/**
 * @author hdx on 2019/5/15.
 */
public class MyDoodleView extends DoodleView {
    private MyTouchEventListener myTouchEventListener;

    public MyDoodleView(Context context, Bitmap bitmap, IDoodleListener listener) {
        super(context, bitmap, listener);
    }

    public MyDoodleView(Context context, Bitmap bitmap, IDoodleListener listener, IDoodleTouchDetector defaultDetector) {
        super(context, bitmap, listener, defaultDetector);
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent event) {
        boolean state = super.dispatchTouchEvent(event);
        if (myTouchEventListener != null) {
            myTouchEventListener.touchEvent(event);
        }
        return state;
    }

    @Override
    public boolean canScrollHorizontally(int direction) {
        return super.canScrollHorizontally(direction);
    }

    public void setMyTouchEventListener(MyTouchEventListener myTouchEventListener) {
        this.myTouchEventListener = myTouchEventListener;
    }

    public interface MyTouchEventListener {
        void touchEvent(MotionEvent event);
    }
}
